/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sk.itat.wicket;

import java.util.ArrayList;
import java.util.Arrays;
import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;

/**
 *
 * @author opteron1441
 */
public final class ReservationPresenRoomPage extends BasePage {

    private Uzivatel person;
    private int rok;
    private int den;
    private int mesiac;
    private int hodiny;
    private int minuty;

    public ReservationPresenRoomPage() {
        super();

        add(new HeaderPanel("mainNavigation", "Reservation Presentation Room"));
    }

    public ReservationPresenRoomPage(Uzivatel params) {
        //TODO:  process page parameters
        super();
        person = params;

        PresentRoomReg presRoom = new PresentRoomReg();
        CompoundPropertyModel presModel = new CompoundPropertyModel(presRoom);

        Form roomForm = new RoomForm("presForm", presModel);

        DropDownChoice hotels = new DropDownChoice("hotel", Arrays.asList(new String[]{"Double Tree, Hlavná 1, Košice", "Maraton Hotel, Terasa 54, Košice", "Carlton, Nabrežná 23, Bratislava", "Hotel Slovan, Slovenská 54, Bratislava",
                    "Hotel republika, Námestie osloboditeľov,Bardejiv", "Hotel Poprad, Duklianská 45, Poprad", "Hotel Tatry, Tatranská Lomnica 20, Tatranská Lomnica"}));
        hotels.setRequired(true);
        TextField nazovLbl = new TextField("nazovPrednasky");
        nazovLbl.setRequired(true);
        TextField dlzkaLbl = new TextField("dlzkaPrednasky");
        dlzkaLbl.setRequired(true);

        ArrayList<String> mesiacList = new ArrayList<String>();
        for (int i = 1; i < 13; i++) {
            mesiacList.add(String.valueOf(i));
        }
        DropDownChoice mesiacLbl = new DropDownChoice("mesiac", new PropertyModel(this, "mesiac"), mesiacList);
        mesiacLbl.setRequired(true);

        ArrayList<String> hodList = new ArrayList<String>();
        for (int i = 0; i < 25; i++) {
            hodList.add(String.valueOf(i));
        }
        DropDownChoice hodLbl = new DropDownChoice("hodiny", new PropertyModel(this, "hodiny"), hodList);
        hodLbl.setRequired(true);

        ArrayList<String> minutyList = new ArrayList<String>();
        for (int i = 0; i < 60; i++) {
            minutyList.add(String.valueOf(i));
        }
        DropDownChoice minutyLbl = new DropDownChoice("minuty", new PropertyModel(this, "minuty"), minutyList);
        minutyLbl.setRequired(true);

        ArrayList<String> denList = new ArrayList<String>();
        for (int i = 1; i < 32; i++) {
            denList.add(String.valueOf(i));
        }
        DropDownChoice denLbl = new DropDownChoice("den", new PropertyModel(this, "den"), denList);
        denLbl.setRequired(true);

        DropDownChoice rokLbl = new DropDownChoice("rok", new PropertyModel(this, "rok"), Arrays.asList(new String[]{"2011", "2012"}));
        rokLbl.setRequired(true);

        CheckBox chect = new CheckBox("verejnaPrednaska");


        roomForm.add(chect);
        roomForm.add(denLbl);
        roomForm.add(dlzkaLbl);
        roomForm.add(hodLbl);
        roomForm.add(hotels);
        roomForm.add(mesiacLbl);
        roomForm.add(minutyLbl);
        roomForm.add(nazovLbl);
        roomForm.add(rokLbl);

        add(roomForm);
        add(new FeedbackPanel("errors"));

        add(new HeaderPanel("mainNavigation", "Reservation Presentation Room"));
    }

    public class RoomForm extends Form {

        public RoomForm(String id, IModel model) {
            super(id, model);

        }

        @Override
        protected void onSubmit() {
            PresentRoomReg regRoom = (PresentRoomReg) getModelObject();
            regRoom.setDatum(den + " . " + mesiac + " . " + rok + " - " + hodiny + ":" + minuty);
            person.getZoznamPrezentacii().add(regRoom);
            System.out.println(regRoom);

            setResponsePage(new WelcomePage(person));

            //setResponsePage(WelcomePage.class, params_uziv);
        }
    }

    public int getDen() {
        return den;
    }

    public void setDen(int den) {
        this.den = den;
    }

    public int getMesiac() {
        return mesiac;
    }

    public void setMesiac(int mesiac) {
        this.mesiac = mesiac;
    }

    public int getRok() {
        return rok;
    }

    public void setRok(int rok) {
        this.rok = rok;
    }

    public int getHodiny() {
        return hodiny;
    }

    public void setHodiny(int hodiny) {
        this.hodiny = hodiny;
    }

    public int getMinuty() {
        return minuty;
    }

    public void setMinuty(int minuty) {
        this.minuty = minuty;
    }
}
